<html>
   <head>
   
   </head>
   <body>
   <script type="text/javascript" src="/_ah/channel/jsapi"></script>
<g:javascript>
   
   sendMessage = function(path, opt_param) {
        path += '?gamekey=' + state.game_key;
        if (opt_param) {
          path += '&' + opt_param;
        }
        var xhr = new XMLHttpRequest();
        xhr.open('POST', path, true);
        xhr.send();
     }
     
     openChannel = function() {
        var token = '${player.channelToken}';
        var channel = new goog.appengine.Channel(token);
        
        var handler = {
          'onopen': function() {},
          'onmessage': function(m) { alert("recieved from server - " + m.data); },
          'onerror': function() {},
          'onclose': function() {}
        };
        var socket = channel.open(handler);

      }
      
     initialize = function() {
        openChannel();
      }
      
      setTimeout(initialize, 100);

function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","/test/sendToClient",true);
xmlhttp.send();
}

</g:javascript>
<div id="myDiv"><h2>Let AJAX change this text</h2></div>
<button type="button" onclick="loadXMLDoc()">Send to server AJAX</button>

      	</body>
</html>



</head>
<body>
